import { View } from "../../../mvc/core/View";
import { GTextFormat } from "../../../common/GTextFormat";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { FontUtil } from "../../../common/font/FontUtil";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { Language } from "../../../../extend/language/Language";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
type int = number;
//class BaseDataListPanel
    
    export  class BaseDataListPanel extends View
    {
        constructor(arg1: Array<any>)
        {
            super();
            this.headTf = new GTextFormat("", 12, 16777113);
            this.titleColumn = [];
            this.titleColumn = arg1;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.bg = ResouceConst.getScaleBitmap(ImagesConst.WindowCenterB);
            this.bg.x = 5;
            this.bg.y = 5;
            addChild(this.bg);
            this.createTitle();
            this.createTileList();
            this.createPageBar();
            this._tipText = ObjCreate.createTextField("", 0, 0, 70, 20, null, new GTextFormat(FontUtil.songtiName, 14, 15788607));
            this._tipText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this.bgWidth = 520;
            this.bgHeight = 320;
            return;
        }

        /* internal  */createTitle(): void
        {
            var loc2=null;
            var loc3=null;
            var loc1=10;
            var loc4=0;
            while (loc4 < this.titleColumn.length) 
            {
                loc2 = this.titleColumn[loc4].name;
                loc3 = new Object /* flash.text.TextField */();
                loc3.x = this.titleColumn[loc4].x;
                loc3.y = 5;
                loc3.height = 25;
                loc3.selectable = false;
                loc3.text = loc2;
                loc3.setTextFormat(this.headTf);
                loc3.autoSize = flash.text.TextFieldAutoSize.LEFT;
                addChild(loc3);
                ++loc4;
            }
            this._tileLine = ObjCreate.createBg(10, 25, 520, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */createTileList(): void
        {
            this.tileList = new GTileList();
            this.tileList.setSize(545, 300);
            this.tileList.columnWidth = 525;
            this.tileList.rowHeight = 25;
            this.tileList.direction = ScrollBarDirection.VERTICAL;
            this.tileList.horizontalGap = 0;
            this.tileList.verticalGap = 3;
            this.tileList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this.tileList.setStyle("cellRenderer", this.rowRender);
            this.tileList.move(0, 30);
            this.dataProvider = new DataProvider();
            this.tileList.dataProvider = this.dataProvider;
            addChild(this.tileList);
            return;
        }

        /* internal  */createPageBar(): void
        {
            this.pageBar = new PageSelecter();
            this.pageBar.mode = PageSelecter.CompleteMode;
            this.pageBar.x = (this.bg.width - this.pageBar.width) / 2;
            this.pageBar.y = this.bg.height - 25;
            addChild(this.pageBar);
            return;
        }

        /* internal  */resize(): void
        {
            return;
        }

        public updateDataProvider(arg1: Array<any>): void
        {
            var loc1=0;
            if (arg1 && arg1.length > 0) 
            {
                this.dataProvider.removeAll();
                loc1 = 0;
                while (loc1 < arg1.length) 
                {
                    this.dataProvider.addItem(arg1[loc1]);
                    ++loc1;
                }
                this.tileList.dataProvider = this.dataProvider;
                if (this._tipText && this.contains(this._tipText)) 
                {
                    this.removeChild(this._tipText);
                }
            }
            else 
            {
                this.tileList.dataProvider = new DataProvider();
                if (this._tipText && !this.contains(this._tipText)) 
                {
                    this.addChild(this._tipText);
                }
                this._tipText.text = Language.getString(57001);
            }
            return;
        }

        public get bgWidth(): int
        {
            return this._bgWidth;
        }

        public set bgWidth(arg1: int)
        {
            this._bgWidth = arg1;
            this.bg.width = arg1;
            if (this.pageBar) 
            {
                this.pageBar.x = (arg1 - this.pageBar.width) / 2;
            }
            if (this._tipText) 
            {
                this._tipText.x = (arg1 - 60) / 2;
            }
            if (this._tileLine) 
            {
                this._tileLine.width = arg1 - 10;
            }
            return;
        }

        public get bgHeight(): int
        {
            return this._bgHeight;
        }

        public set bgHeight(arg1: int)
        {
            this._bgHeight = arg1;
            this.bg.height = arg1;
            if (this.pageBar) 
            {
                this.pageBar.y = this.bg.height - 20;
            }
            if (this._tipText) 
            {
                this._tipText.y = (arg1 - this._tipText.height) / 2;
            }
            return;
        }

        public /* var */pageBar: PageSelecter;

        public /* var */tileList: GTileList;

        protected /* var */bg: ScaleBitmap;

        protected /* var */rowRender: GCellRenderer;

        protected /* var */_tileLine: Object /* flash.display.Bitmap */;

        protected /* var */_tipText: Object /* flash.text.TextField */;

        protected /* var */headTf: Object /* flash.text.TextFormat */;

        protected /* var */titleColumn: Array<any>;

        protected /* var */dataProvider: DataProvider;

        /* internal */ /* var */_bgWidth: int;

        /* internal */ /* var */_bgHeight: int;
    }
